/*
 * Copyright 2008 Wink Saville
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.saville.testmc;

import android.os.IBinder;
import android.os.Bundle;
import android.content.Intent;

import com.saville.debug.Log;
import com.saville.mc.*;
import com.saville.msgcomp.Msg;

public class TestMcService extends McService {
    static final int GUID = -2;
    static final int CMD_GOING = 1;

    /*
     * We must let McService.onCreate run also
     */
    @Override
    public void onCreate() {
        df = Log.VERBOSE;
        Log.print("TestMcService: onCreate; tid=%d E", Thread.currentThread().getId());
        super.onCreate("TestMcService");

        Msg msg = getMsg(lookup("TestMc"), GUID, CMD_GOING);
        sendMsg(msg);

        Log.print("TestMcService: onCreate; X");
    }

    @Override
    public void processMsg(Msg msg) {
        Log.v(df, "%s: tid=%d cmd=%d", mName, Thread.currentThread().getId(), msg.cmd);

        if (msg.guid == 1) {
            Log.v(df, "%s: keyCode=%d", mName, msg.arg1);
        }
}

    @Override
    public void onStart(int startId, Bundle args) {
        Log.print("TestMcService: onStart; EX tid=%d startId=%d args.size=%d",
            Thread.currentThread().getId(), startId, args == null ? null : args.size());
    }

    /*
     * We must let McService.onDestry run also
     */
    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.print("TestMcService: onDestroy; EX tid=%d", Thread.currentThread().getId());
    }

    /*
     * This test service has no binder
     */
    @Override
    public IBinder onBind(Intent intent) {
        Log.print("TestMcService: getBinder; EX tid=%d", Thread.currentThread().getId());
        return null;
    }

}
